home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
manchest.lha
/
MANCHESTER
/
manchester
/
2.2
/
ControllerID.st
< prev
next >
Wrap
Text File
|
1993-07-24
|
4KB
|
137 lines
" NAME ControllerID
AUTHOR rmd@cs.man.ac.uk
FUNCTION adds a unique id to each controller
ST-VERSIONS 2.2
PREREQUISITES
CONFLICTS
DISTRIBUTION world
VERSION 1.1
DATE 22 Jan 1989
SUMMARY ControllerID
Adds a unique ID to each controller - this is not
dependent on OOP or time, but only on the sequence in which a
controller spawns other controllers. This takes a long time to file
in since it adds two instance variables to controller and
re-compiling all controllers is a lengthy process.(2.2). RMD.
"!
'From Smalltalk-80, Version 2.3 of 13 June 1988 on 19 June 1989 at 12:42:37 pm'!
!Behavior methodsFor: 'accessing instances and variables'!
allSubInstances
"Answer a collection of all instances of subclasses of this class. this does not include instances of this class."
| collection |
collection _ OrderedCollection new.
self allSubInstancesDo: [:each | collection add: each].
^collection! !
Controller addInstVarName: 'controllerID'!
Controller addInstVarName: 'childCount' !
!Controller methodsFor: 'private'!
controllerID: aString
"This should never be sent unless you really know what you are doing!!
If you do send this, make sure that the ID you assign is unique.
When this is set I reset the childCount."
controllerID _ aString.
childCount _ 0! !
!Controller methodsFor: 'printing'!
printOn: aStream
"Append to the argument aStream a sequence of characters that identifies the receiver."
super printOn: aStream.
aStream nextPutAll: ' (', self controllerID, ')'.! !
!Controller methodsFor: 'generation access'!
controllerID
"Answer with my unique identifier."
^controllerID!
nextChildID
"Return the identifier of my next child. Used as a way of generate unique controller IDs"
childCount_childCount + 1.
^controllerID, '.', (childCount printString)! !
!Controller class methodsFor: 'CID initialisation'!
initialiseCID
"Initialise all the currently exisiting processes with unique IDs. Prompt
for the basenames aString."
"Controller initialiseCID"
self initialiseCID: (FillInTheBlank request: 'Basename for these controllers')!
initialiseCID: aString
"Initialise all the currently exisiting controllers with unique IDs based
on the basename aString, concatenated with a count."
| controllerList |
controllerList _ Controller allSubInstances.
controllerList addAll: Controller allInstances.
1 to: controllerList size do: [:each | (controllerList at: each)
controllerID: aString , '.' , each printString]! !
!Controller class methodsFor: 'instance creation'!
new
"Fix it so that all newly created instances just get a fixed
string until all methods are properly installed. Then make sure that
all existing instances include a string, then install the real
method."
| newController |
newController _ super new.
newController controllerID: 'dummy'.
newController initialize.
^newController! !
Controller initialiseCID: 'dummy'!
!Controller class methodsFor: 'instance creation'!
new
"Create a new instance of controller. To all the initialisation for it
and instal and prropriate CID."
| newController |
newController _ super new.
ScheduledControllers activeController isNil
"If there is no active controller the interrupt key was pressed while it was searching
for a new controller. If it was just will in with a dummy controller name."
ifTrue:
[newController controllerID: 'interrupt']
ifFalse: [newController controllerID: ScheduledControllers activeController nextChildID].
newController initialize.
^newController! !
Controller comment:
'A Controller coordinates a view, its model, and user actions.
Instance Variables:
model <Object | Model>
view <View>
sensor <InputSensor>
childCount <Integer> Used to generate the CID of any child controllers
controllerID <String> My CID'!